import Taro from "@tarojs/taro"
 
export function saveHistory(searchName){
    if(searchName.length == 0){
        return
    }
    var history:any[] = getHistory()
    var have = history.includes(searchName)
    if(have){
        return 
    }
    history.push(searchName)
    Taro.setStorageSync('history-list', history)
}

export function getHistory(){
    var history_list =  Taro.getStorageSync('history-list')
    if(history_list && history_list !== undefined){
        return history_list
    }   
    return []
}

export function clearHistory(){
    Taro.setStorageSync('history-list', [])
}